window.onload = function () {
	// 选择将观察突变的节点
	var targetNode = document.getElementsByTagName("html")[0];
	var QuestionHeader = document.getElementsByClassName("QuestionHeader-title")[0];
	if (QuestionHeader) {
		QuestionHeader.style.cssText = "display:none";
	}
	function hideWater() {
		var container = document.getElementsByClassName("water-container");
		for (let i = 0; i < container.length; i++) {
			container[i].style.cssText = "display:none";
		}
		if (document.getElementsByClassName("s-menu-item")[0]) {
			document.getElementsByClassName("s-menu-item")[1].style.cssText = "display:none";
			document.getElementsByClassName("s-menu-item")[2].style.cssText = "display:none";
		}
	}

	hideWater();

	if (document.getElementById("con-ar")) {
		document.getElementById("con-ar").innerHTML = "";
	}

	// 观察者的选项(要观察哪些突变)
	var config = { attributes: false, childList: true, subtree: true };
	// 当观察到突变时执行的回调函数
	var callback = function (mutationsList) {
		mutationsList.forEach(function (item, index) {
			if (item.type == "childList") {
				if (document.getElementById("con-ar")) {
					document.getElementById("con-ar").innerHTML = "";
				}
			}
		});
	};
	if (document.getElementById("content_right")) document.getElementById("content_right").style.cssText = "display:none";
	// 创建一个链接到回调函数的观察者实例
	var observer = new MutationObserver(callback);

	// 开始观察已配置突变的目标节点
	observer.observe(targetNode, config);
};

window.beforeunload = function () {
	if (document.getElementById("content_right")) document.getElementById("content_right").style.cssText = "display:none";
};

var _wr = function (type) {
	let orig = window.history[type];
	return function () {
		let rv = orig.apply(this, arguments);
		let e = new Event(type.toLowerCase());
		e.arguments = arguments;
		window.dispatchEvent(e);
		return rv;
	};
};

window.history.pushState = _wr("pushState");
window.history.replaceState = _wr("replaceState");
window.addEventListener("pushstate", function (event) {
	// alert('pushstate')
});
window.addEventListener("replacestate", function (event) {
	// alert('replacestate')
});

// document.getElementsByTagName("body")[0].onhashchange = function () {
//     alert("URL产生了变化")
// };
